%%

%class Scanner
%implements TokenKinds
%function nextToken
%type Token
%state COMMENT
%unicode
%line
%column

%{
 
  /**
   * Utility methode om een token te maken.
   * @param kind token soort
   * @see TokenKinds
   */
  private Token createToken(int kind) {
    return new Token(kind,yyline+1,yycolumn+1,yytext());
  }

%}

LineTerminator = \r|\n|\r\n
WhiteSpace     = [ \t\f]
Terminal       = ([:jletter:]|[:jletterdigit:])+
NonTerminal    = "<" ([:jletter:]|[:jletterdigit:])+ ">"
Assignment     = "::="
Empty	       = "E"

%%

<YYINITIAL> {

"|"             {return createToken(OR);}
{Terminal}      {return createToken(TERMINAL);}
{NonTerminal}	{return createToken(NONTERMINAL);}
{Assignment}	{return createToken(ASSIGNMENT);}
{Empty}		{return createToken(EMPTY);}

{LineTerminator} {return createToken(EOL); }

<<EOF>>         { return createToken(EOF);}
{WhiteSpace}    {}
.|\n            {throw new RuntimeException(yytext()+" unmatched");}

}
